#include <stdio.h>

int func(int a, int b) {
    int (*pf)(int, int) = func;
    int c               = a + b;
    int c_arry[4]       = {0};
    printf("%p %p %p  %p %p %p\n", &a, &b, &c, &c_arry, &c_arry[0], &c_arry[1]);
    {
        int d = c;
        printf("d ptr = %p\n", &d);
    }
    for (int i = 0; i < 6; ++i)
        printf("arr[%d] is %p\n", i, &c_arry[i]);

    printf("func ptr is %p %p\n", pf, &pf);

    /** 栈内数据存储顺序:
     * c_arry
     * pf
     * d
     * c
     * a 从右向左入栈，方便解析不定参数
     * b b的地址最低，显示栈是从低到高开始扩展(!可能是虚拟机的缘故，正常情况下应该是从高到低)
     * 函数返回地址
     */

    return a + b;
}

int main(int argc, char** argv) {
    int (*pf)(int, int) = func;

    printf("func ptr is %p\n", pf);

    int c = pf(1, 2);
    int d = pf(3, 4);
    (void)c;
    (void)d;

    return 0;
}
